(function($){
  $.fn.forms = function() {

$('form.inline').live('submit',function(event){
	event.preventDefault();
var _this=$(this);
	_this.find('.element-error').removeClass('element-error');
	var action=_this.attr("action");
	var data=_this.serialize();
	var _settings=_this.find('input.settings').val();
	json = JSON.parse(_settings);	//	var aun=
// perhaps add an iframe if needed....
	var req=0;
	var error_array=new Array();
	$(".req",_this).each(function(){
	var e=$(this);
	if(e.val()=='') {
		e.addClass('element-error');
		req++;

	
	} else {
		e.removeClass('element-error');	
	}
	
	});
	if(req>=1) {

		
		return false;	
	}
	var toUpdate=(json.updateNode.length>=2) ? json.updateNode : '#response'; 
	// an ajax spinner could be put here too!
	
	
	
	
	
	
	
	var submit_button=_this.find(':submit');
	var sbov=submit_button.val();
	submit_button.attr("disabled",true).addClass('button-loading').val(json.buttonWaitingValue);
	
	
	$.post(action,data,function(data,a,b){
		
		//console.log(b.getAllResponseHeaders());
		$(toUpdate).html(data);
		submit_button.val(sbov).attr("disabled",false).removeClass('button-loading');
	});
	
	// update it after
	// simulate something
	//setTimeout(function(){
//	submit_button.val(sbov).attr("disabled","");
//	},2000);
});
return this;
  };
})(jQuery);